<?php
/**
 * 建筑模板
 * 
 * Created	: 2010-10-14
 * Modified : 2010-10-18
 * @author  : 陈立强
 */
class Tbuilding {
	
	public static $tbl = 'template_building';
	
	public static function init()
	{
		
	}
	
	/**
	 * 获取指定建筑的模板数据
	 * @param int $tb_id
	 */
	public static function getInfo($tb_id)
	{
		// 获取建筑模板信息
		$tbList = C('build/tbuild');
		return $tbList[$tb_id];
	}
	
	/**
	 * 根据建筑标志获取模板数据
	 * @param int $tb_sign
	 */
	public static function getInfoBySign($tb_sign)
	{
		// 获取建筑模板信息
		$tbList = C('build/tbuild_sign');
		return $tbList[$tb_sign];
	}
	
	/**
	 * 获取所有建筑列表
	 */
	public static function getList()
	{
		// 获取建筑模板信息
		$tbList = C('build/tbuild');
		return $tbList;
	}
	
	/**
	 * 缓存建筑表模板数据
	 */
	public static function cache()
	{
		global $DB, $L, $G;
		$sql = 'SELECT * FROM '.self::$tbl.' WHERE state>0 order by tb_id asc';
		$list = $DB->getList($sql);
		$tbList = array();
		$tbSignList = array();
		foreach ($list as $v) {
			$tbList[$v['tb_id']] = $v;
			$tbSignList[$v['sign']] = $v;
		}
		
		$tbFile = $G['path_data'].'inc/tbuild.data.php';
		$tbSignFile = $G['path_data'].'inc/tbuild_sign.data.php';
		
		UC('build/tbuild', $tbList);
		UC('build/tbuild_sign', $tbSignList);
		
		return true;
	}
}